﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for Functions
/// </summary>
public static class Functions
{
    public static ListItemCollection GetSelectedListBoxItems(ListBox l)
	{
        ListItemCollection selectedItems = new ListItemCollection();
        foreach (ListItem item in l.Items)
        {
            if (item.Selected)
            {
                selectedItems.Add(item);
            }
        }
        return selectedItems;
	}

    public static int GetUserId()
    {
        try
        {
            CustomIdentity ident = (CustomIdentity)HttpContext.Current.User.Identity;
            return Convert.ToInt32(ident.Ticket.UserData);
        }
        catch (Exception) {
            return -1;
        }
    }
}